package org.example.secondkill.redis;

public abstract class BasePrefix implements KeyPrefix {
    /**
     * 0 表示永不过期
     */
    private final int expireSeconds;

    /**
     * 前缀
     */
    private final String prefix;

    public BasePrefix(int expireSeconds, String prefix) {
        this.expireSeconds = expireSeconds;
        this.prefix = prefix;
    }

    public BasePrefix(String prefix) {
        this(0, prefix);
    }

    public static void main(String[] args) {
        System.out.println(BasePrefix.class.getSimpleName());
    }

    @Override
    public int expireSeconds() {
        return this.expireSeconds;
    }

    @Override
    public String getPrefix() {
        String className = getClass().getSimpleName();
        return className + ":" + this.prefix;
    }
}
